import socket
 
# 创建 Socket
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
# 连接到服务端
client_socket.connect(("localhost", 12345))
 
# 发送数据
client_socket.send("你好，服务器！".encode("utf-8"))
 
# 接收响应
response = client_socket.recv(1024).decode("utf-8")
print(f"服务器响应：{response}")
 
# 关闭连接
client_socket.close()